package cn.jaye.fabric.common.util;

/**
 * @author Jaye
 * @create 2018-06-01 14:20
 */
public class StringUtil {

    public static String printableString(final String string) {
        int maxLogStringLength = 64;
        if (string == null || string.length() == 0) {
            return string;
        }

        String ret = string.replaceAll("[^\\p{Print}]", "?");

        ret = ret.substring(0, Math.min(ret.length(), maxLogStringLength)) + (ret.length() > maxLogStringLength ? "..." : "");

        return ret;
    }
}
